package org.lanqiao.lg.dao.impl;

import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.lanqiao.bean.Images;
import org.lanqiao.lg.dao.ImagesDao;
import org.lanqiao.tools.BaseDao;

public class ImagesDaoImpl extends BaseDao implements ImagesDao {

//	@Override 图片上传 获取id存表
	public Integer upLoadImg(Images info) {
		try {
			 query.update("INSERT INTO images(imageName,imageType,imageShowIds,date,b1) VALUES(?,?,1,NOW(),1)",
					info.getImageName(), info.getImageType());
			 return query.query("SELECT id FROM images WHERE imageName=?", new ScalarHandler<Integer>(),info.getImageName());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer downImg() {
		// TODO Auto-generated method stub
		return null;
	}

//	@Override 通过图片id 查询图片名字
	public String searchImgName(Integer id) {
		try {
			 return query.query("SELECT imageName FROM images WHERE id=?", new ScalarHandler<String>(),id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
